﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using ConciseMarkupLanguage.Utils;
using Irony.Ast;
using Irony.Interpreter;
using Irony.Parsing;

namespace ConciseMarkupLanguage.Ast
{
    class TermListNode : AstNode
    {
        public override void Init(ParsingContext context, ParseTreeNode treeNode)
        {
            base.Init(context, treeNode);
            foreach (var node in treeNode.ChildNodes)
                AddChild("term", node);
        }

        public override void EvaluateNode(EvaluationContext context, AstMode mode)
        {
            var list = new List<object>();
            foreach (var node in ChildNodes)
            {
                node.Evaluate(context, AstMode.Read);
                list.Add(context.Data.Pop());
            }
            context.Data.Push(list);
        }
    }
}
